package cn.com.db.service;

import cn.com.db.model.StoreDeck;
import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class StoreDeckService extends BaseService{

    public StoreDeck getStoreDeckById(String id){
        return storeDeckDao.getStoreDeckById(id);
    }

    public StoreDeck getStoreDeckOfStore(String storeId,String deckId){
        return storeDeckDao.getStoreDeckOfStore(storeId,deckId);
    }

    public Boolean isExist(String id){
        if (StringUtils.isBlank(id)){
            return false;
        }
        return getStoreDeckById(id)!=null;
    }

    public Boolean isAlive(String id){
        if (StringUtils.isBlank(id)){
            return false;
        }
        StoreDeck storeDeck=getStoreDeckById(id);
        if (storeDeck!=null&&!storeDeck.getDel()){
            return true;
        }
        return false;
    }

    public List<StoreDeck> getStoreDeck(String store,String parent){
        return storeDeckDao.getStoreDeck(store,parent);
    }

    public Integer countStoreDeck(String store,String parent){
        return storeDeckDao.countStoreDeck(store,parent);
    }

    public void onDeck(StoreDeck storeDeck){
        storeDeckDao.createStoreDeck(storeDeck);
    }

    @Transactional
    public void updateDeck(StoreDeck storeDeck){
        storeDeckDao.update(storeDeck);
    }

}
